<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>插件列表</h2>
	</div>
    <div class="cf">
      <div class="fl">
			<div class="tools"> 
            <a href="{:U('create')}" class="btn">快速创建</a><a href="{:U('sort')}" class="btn">已装插件后台 [菜单排序]</a>
			</div>
		</div>

        <!-- 高级搜索 -->
		<div class="search-form fr cf">
        <select name="key">
            <option value="title">名称</option>
            <option value="name">标识</option>
            <option value="description">描述</option>
            <option value="author">作者</option>
            </select>
			<div class="sleft">   
				<input type="text" name="word" class="search-input" value="{:I('word')}" placeholder="请输入关键字">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
			</div>
         
		</div>
    </div>

	<!-- 数据列表 -->
	<div class="data-table table-striped">
		<table>
			<thead>
				<tr>
					<th >名称</th>
					<th  >标识</th>
					<th >描述</th>
					<th width="45px">作者</th>
					<th width="45px">版本</th> 
                    <th width="45px">状态</th>
                    <th width="45px">锁定</th>  
					<th >操作</th>
				</tr>
			</thead>
			<tbody>
				<notempty name="_list">
				<volist name="_list" id="vo">
				<tr>
					<td >{$vo.title}</td>
					<td >{$vo.name}</td>
					<td>{$vo.description}</td>
					<td><a target="_blank" href="{$vo.url|default='/'}">{$vo.author}</a></td>
					<td>{$vo.version}</td> 
                    <td>{$vo.status_text|default="未安装"}</td>
                    <td>{$vo.is_locked_text|default="未知"}</td>
					<td>
						<empty name="vo.uninstall">
							<?php
								$class	= get_addon_class($vo['name']);
								if(!class_exists($class)){
									$has_config = 0;
								}else{
									$addon = new $class();
									$has_config = count($addon->getConfig());
								}
							?>
							<?php if ($has_config): ?>
								<a href="{:U('config',array('id'=>$vo['id']))}">设置</a>
							<?php endif ?>
                        <?php if ($vo['is_locked'] >=0): ?>
							<eq name="vo.is_locked" value="0">
								<a class="ajax-get" href="{:U('lock',array('id'=>$vo['id']))}">锁定</a>
							<else />
								<a class="ajax-get" href="{:U('unlock',array('id'=>$vo['id']))}">解锁</a>
							</eq>
						<?php endif ?>
						<?php if ($vo['status'] >=0): ?>
							<eq name="vo.status" value="0">
								<a class="ajax-get" href="{:U('enable',array('id'=>$vo['id']))}">启用</a>
							<else />
								<a class="ajax-get" href="{:U('disable',array('id'=>$vo['id']))}">禁用</a>
							</eq>
						<?php endif ?>   
							{// <eq name="vo.author" value="thinkphp">}
								<a class="ajax-get" href="{:U('uninstall?id='.$vo['id'])}">卸载</a>
							{// </eq>}
						<else />
							<a class="ajax-get" href="{:U('install?addon_name='.$vo['name'])}">安装</a>
						</empty>
					</td>
				</tr>
				</volist>
				<else/>
				<td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
			</tbody>
		</table>
	</div>
	<!-- 分页 -->
    <div class="page">
        {$_page}
    </div>
</block>
<block name="script">
	<script type="text/javascript">
		$(function(){

	        //搜索功能
			$('.search-form').find('select').val("{:I('key')}"||"title");
			$("#search").click(function(){
				var url = $(this).attr('url');
		        var query  = $('.search-form').find('input').serialize();
				query+="&"+$('.search-form').find('select').serialize();
		        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
		        query = query.replace(/^&/g,'');
		        if( url.indexOf('?')>0 ){
		            url += '&' + query;
		        }else{
		            url += '?' + query;
		        }
				window.location.href = url;
			});
			$('.data-table th:last').attr('width',70);
		    //回车自动提交
		    $('.search-form').find('input').keyup(function(event){
		        if(event.keyCode===13){
		            $("#search").click();
		        }
    		});
		})
	</script>
    <script type="text/javascript">
		$(function(){
			//导航高亮
			highlight_subnav('{:U('Addons/index')}');
		})
	</script>
</block>